<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            margin: 100px auto;
        }
    </style>
</head>
<body>
    <div>
        <button class="btn1">开灯</button>
        <button class="btn2">关灯</button>
    </div>
    <script>
        var btn1 = document.querySelector('.btn1');
        var btn2 = document.querySelector('.btn2');
        var bodyEle = document.body;
        btn1.onclick = function(){
            bodyEle.style.backgroundColor = 'white';
        }
        btn2.onclick = function(){
            bodyEle.style.backgroundColor = 'black';
        }
    </script>
</body>
</html>